package com.ck.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ck.entity.MHusTimes;
import com.ck.entity.MRedBlack;
import com.ck.entity.MRoomRecord;
import com.ck.entity.MRoomUser;
import com.ck.mapper.MRoomRecordMapper;
import com.ck.mapper.MRoomUserMapper;
import com.ck.service.MRoomRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 房间历史记录表(MRoomRecord)表服务实现类
 *
 * @author ck
 * @since 2020-11-06 15:44:02
 */
@Service("mRoomRecordService")
public class MRoomRecordServiceImpl extends ServiceImpl<MRoomRecordMapper, MRoomRecord> implements MRoomRecordService {

    @Resource
    private MRoomRecordMapper roomRecordMapper;
    @Resource
    private MRoomUserMapper mRoomUserMapper;
    @Resource
    private MHusTimes mHusTimes;
    @Resource
    private MRedBlack mRedBlack;

    /**
     * 结算
     * @param roomRecord
     * @return
     */
    @Override
    public boolean settlement(MRoomRecord roomRecord) {
        boolean flag = true;
        //获取当前房间所有用户
        List<MRoomUser> mRoomUsers = mRoomUserMapper.selectList(new LambdaQueryWrapper<MRoomUser>().eq(MRoomUser::getRoomId, roomRecord.getRoomId()));

        //红黑胡类型, 普通-1, 其他对应m_red_black表type字段
        int type = roomRecord.getRedBlackType();
        if(type == -1){

        }
        int i = roomRecordMapper.insert(roomRecord);
        if(i<0){
            flag = false;
        }
        return flag;
    }
}
